<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="../../../resources/templates/login.xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:sec="http://www.springframework.org/security/facelets/tags" >


    <ui:define name="menu_horizontal">
        <sec:ifAnyGranted roles="ROLE_ADMIN,ROLE_FUNC">
            <ui:include src="/pages/site/funcionario/menu.xhtml" />
        </sec:ifAnyGranted>
    </ui:define>
    
    <ui:define name="corpo">

        <sec:ifAnyGranted roles="ROLE_ADMIN,ROLE_FUNC">
            
            <h:form id="formEvent">
                <!--<p:messages id="messages"/>-->
                
                <p:schedule id="schedule" value="#{scheduleController.eventModel}" widgetVar="myschedule" allDaySlot="false" minTime="8am" maxTime="6pm" showWeekends="false"
                            rightHeaderTemplate="agendaWeek" draggable="false" leftHeaderTemplate="prev,next" view="agendaWeek">  
  
                    <p:ajax event="dateSelect" listener="#{scheduleController.onDateSelect}" update="eventDetails" oncomplete="eventDialog.show()" />  
                    <p:ajax event="eventSelect" listener="#{scheduleController.onEventSelect}" update="eventDetails" oncomplete="eventDialog.show()" />  
                    <!--<p:ajax event="eventMove" listener="#{scheduleController.onEventMove}" update="messages" />  
                    <p:ajax event="eventResize" listener="#{scheduleController.onEventResize}" update="messages" />-->

                </p:schedule>  

                <p:dialog widgetVar="eventDialog" header="Detalhes do agendamento" showEffect="clip" hideEffect="clip" modal="true" closable="true">  
                    <h:panelGrid id="eventDetails" columns="2">
                        
                        <h:outputText value="Serviços: *"/>
                        <p:selectOneMenu value="#{scheduleController.agenda.servico}" converter="#{ServicoConverter}">
                            <f:selectItem itemLabel="-- Selecione --" noSelectionOption="true"/>
                            <f:selectItems value="#{controllerServico.lista}" var="tipo" itemValue="#{tipo}" itemLabel="#{tipo.tipo} | R$ #{tipo.preco}"/>
                        </p:selectOneMenu> 

                        <h:outputLabel for="from" value="Dia: *" />  
                        <p:inputMask id="from" value="#{scheduleController.event.startDate}" mask="99/99/9999">  
                            <f:convertDateTime pattern="dd/MM/yyyy" />  
                        </p:inputMask> 
                        
                        <h:outputText value="Hora: *"/>
                        <p:calendar value="#{scheduleController.event.startDate}" pattern="HH:mm" timeOnly="true"/>

                        
                    </h:panelGrid>  
                    
                    <p:commandButton value="Salvar" actionListener="#{scheduleController.salvar()}" oncomplete="myschedule.update();eventDialog.hide();"/>
                </p:dialog>
            </h:form>
                
            
        </sec:ifAnyGranted>
    </ui:define>



</ui:composition>